package swing;

import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

import javax.swing.JFrame;

import engine.GameRO;
import engine.View;

public class GameFrame extends JFrame implements View {

	private static final long serialVersionUID = 1L;
	private int i = 0;

	public GameFrame() {
		setVisible(true);
		setFocusable(false);
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	}

	@Override
	public void update(GameRO game) {
		try {
			if (i > 30 && (i = 0) == 0)
				setTitle(game.getName() + ":" + game.getCurrentRoom().getName() + " | FPS " + game.getFPS() + " | Speed " + game.getFPSFactor());
			else
				i++;
		} catch (NullPointerException e) {}
	}

	public void goFullScreen() {
		GraphicsDevice sd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
		if (sd.isFullScreenSupported())
			sd.setFullScreenWindow(this);
	}

	public void backFormFullScreen() {
		GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().setFullScreenWindow(null);
	}

}
